//
//  FriendWebViewController.m
//  BuffetNews
//
//  Created by 李荃荃 on 14-11-12.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "FriendWebViewController.h"
#import "Reachability.h"
#import <SystemConfiguration/SystemConfiguration.h>
@interface FriendWebViewController ()<UIWebViewDelegate>

@end

@implementation FriendWebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
     [self LoadingView];
}
- (void)LoadingData
{
     BOOL reachable = [[Reachability reachabilityForInternetConnection] isReachable];
    if (!reachable) {
//        UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
//        button.frame = CGRectMake(5, self.view.frame.size.height / 13 * 12, self.view.frame.size.width / 7, self.view.frame.size.height / 14 );
//        [button setBackgroundImage:[UIImage imageNamed:@"btn_home.png"] forState:UIControlStateNormal];
//        [button addTarget:self action:@selector(block:) forControlEvents:UIControlEventTouchUpInside];
//        [self.view addSubview:button];
        UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"该功能需要连接网络才能使用，请检查您的网络连接状态" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil] autorelease];
        [alertView show];
        
        
        
    } else {
        
    }
}


- (void)LoadingView
{
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, self.view.frame.size.height - 64)];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.apiString]];
    [webView loadRequest:request];
    webView.scalesPageToFit = YES;
    webView.delegate = self;
    [self.view addSubview:webView];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(5, 10, 50, 50);
    [button setTitle:@"< 返回" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button];
}

- (void)buttonClicked:(UIButton *)button
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
   
}
- (void)dealloc
{
    [_apiString release];
    [super dealloc];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
